#pragma once
//============================================================================
// Copyright (C) 2009-2013 Brett R. Jones 
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses 
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#include <RcSysPktLib/RcSysPktTypes.h>

class RcSktBase;
class RcSysPktHdr;

// example class for pkt handlers ease of coding
class RcSysPktHandler
{
public:
	//=== constructor ===//
	RcSysPktHandler();
	//=== constructor ===//
	virtual ~RcSysPktHandler();


	//=== packet handler methods ===//
	//! Handle Incoming packet.. use function jump table for speed
	virtual long RcSysHandlePkt		( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}

	//=== packet handlers ===//
	virtual long OnPktUnhandled			( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktInvalid			( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}

	virtual long OnPktDie				( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktAuth				( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktAnnList			( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktAnnounce			( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktFindNode			( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}

	virtual long OnPktOfferSystemMsg	( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktAnnTronacomUpdate	( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktPatch				( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktPing				( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktPong				( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}

	virtual long OnPktRelayServiceReq	( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktRelayServiceReply	( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktRelayConnectReq	( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktRelayConnectReply	( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktRelayUserDisconnect( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}

	virtual long OnPktSearchReq			( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktSearchReply		( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktFindFileReq		( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}
	virtual long OnPktFindFileReply		( RcSktBase * poSkt, RcSysPktHdr * poPktHdr ){return 0;}

	//packet type 250 and greater not allowed except for system packets
	typedef long (RcSysPktHandler::*TC_SYS_BASE_PKT_FUNCTION)( RcSktBase *, RcSysPktHdr * );  
protected:
	//=== vars ====//
	TC_SYS_BASE_PKT_FUNCTION m_aBaseSysPktFuncTable[ MAX_SERVICE_PKT_TYPE_CNT + 2 ];
};